var app = getApp(), api = require('../../../../api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    
  },
  onShow:function(){
   this.mylist();
  
  },
  onLoad: function () {
    var that = this
    that.setData({
      icons: wx.getStorageSync('site') + '/addons/sd_liferuning/tp/public/uploads/background',
    })
  },
  mylist:function(){
    var that = this;
    app.request({
      url: api.card.mylist,
      data: {
        uid: wx.getStorageSync('uid')
      },
      success: function (e) {
        that.setData({
          data: e.data
        })
      }
    })
  }
  ,
  bankSetup: function (e) {
    var that = this;
    let _id = e.currentTarget.dataset.id;
    // TODO 发送请求
    app.request({
      url:api.card.default,
      data:{
        uid:wx.getStorageSync('uid'),
        id:_id,
      },
      success:function(e){
       if(e.data==1){
      
         wx.showModal({
           title: '提示',
           content: '设置成功',
           showCancel: false,
           success:function(){
             that.mylist();
           }
         })
       }else{
         wx.showModal({
           title: '提示',
           content: '设置失败',
           showCancel:false
         })
       }
        
      }
    })
 
  }
  ,
  del:function(e){
    var that=this;
    var _id = e.currentTarget.dataset.id;
      wx.showModal({
        title: '提示',
        content: '您确定删除吗',
        success:function(e){
          if(e.confirm==1){
            app.request({
              url:api.card.del,
              data:{
                id: _id
              },
              success:function(e){
                that.mylist();
              }
            })
          }
        }
      })
  }
})